module.exports = function(app, opt) {

  const options = this.options
  Object.assign(this.config, opt.config || {})
  Object.assign(this.modules, opt.modules || {})
  Object.assign(options, opt)
  if(options.db){
    options.db.host = options.db.host || 'localhost'
    options.db.port = options.db.port || 27017
    if(options.db.user && options.db.pwd)
      this.linkDatabase(app)
    else
      options.init(app)
  }else{
    options.init(app)
  }

  return app

}
